<!DOCTYPE html>
<html lang="en" xmlns:zxw="http://www.w3school.com.cn"  >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首页</title>
    <link rel="stylesheet" href="../../../js/common/layui/css/layui.css">
    <link rel="stylesheet" href="../../../css/common/animate.css" />
    <link rel="stylesheet" href="../../../css/common/bootstrap/css/bootstrap.css" />
    <link rel="stylesheet" href="../../../css/common/bootstrap/treeview/bootstrap-treeview.css" />
    <link rel="stylesheet" href="../../../css/common/common.css" />
</head>
<body class="layout-zxw" >
    <!-- 标注那些参数会存在多个 -->
    <input type="hidden" id="mult" name="mult" value="authority,authority_url,authorityid" >
    <form id="form1" class="layui-form container-fluid" action="" lay-filter="form" >
        <!-- 记录权限删除信息 -->
        <input type="hidden" id="delete_power_id" name="delete_power_id" value="," >
        <fieldset class="layui-elem-field layui-field-title">
            <legend>菜单基本信息</legend>
            <zxw:select parcel="true" parcelName="父级菜单" id="supper_id" url="URL.INDEX.GETMENULIST" multiple="true" name="supper_id" field_name_key="menu_name" field_value_key="id" ></zxw:select>
            <zxw:input id="menu_name" name="menu_name" type="text" parcelName="菜单名称" lay_verify="required" parcel="true" placeholder="请填写菜单名称" ></zxw:input>
            <zxw:input id="icon" name="icon" type="text" parcelName="菜单图标" lay_verify="" parcel="true" placeholder="当没有对应的父级菜单时，菜单url不填写，菜单图标需要填写，否则图标不填写，菜单url需要填写" ></zxw:input>
            <zxw:input id="orderby" maxlength="3" name="orderby" type="text" parcelName="菜单顺序" lay_verify="number" parcel="true" placeholder="请填写菜单顺序" ></zxw:input>
            <zxw:input id="menu_url" lay-verify="required" name="menu_url" parcel="true" parcelName="链接URL" placeholder="当没有对应的父级菜单时，菜单url不填写，菜单图标需要填写，否则图标不填写，菜单url需要填写" ></zxw:input>
        </fieldset>
        <fieldset class="layui-field-title layui-elem-field ">
            <legend>菜单权限</legend>
            <div class="layui-field-box">
                <button class="layui-btn layui-btn-small" onclick="return addMenu.addPower();" ><i class="layui-icon"></i> 添加</button>
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>权限名称</th>
                        <th>权限url</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </fieldset>
    </form>
    <!--<script src="../../../js/common/jquery/jquery-1.11.1.js" ></script>-->
    <script type="application/javascript" src="../../../js/common/own/own.js?layui,jquery,treeview,njzxw,URL,menu" >
        njzxw.layui.val({
            url:URL.INDEX.GETMENUMAP,
            gather:['supper_id'],
            paramExe:function(data){
                data.supper_menu_id = data.supper_id;
                data.supper_menu_id = data.supper_id;
                return data;
            },
            fun:addMenu.loadData
        });
        njzxw.layui.submit({
            url:URL.INDEX.SAVEMENU,
            againparams:true,
            prepFun:function(data){
                var cnt = $('select').size();
                console.log(data);
                var supper_id1 = data['supper_id'+(cnt-1)];
                var supper_id2 = data['supper_id'+(cnt-2)];
                // alert(supper_id1+"=="+supper_id2);
                data['supper_menu_id'] = (supper_id1 == ''?((supper_id2 != '' && supper_id2 != undefined)?supper_id2:supper_id1):supper_id1);
// alert(data['supper_menu_id']);
                return data;
            }
        });

        addMenu.init();

    </script>
</body>
</html>